package elcs.board.model;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

@Service
public class BoardServiceImpl implements BoardService {
	@Resource(name="boardDaoImpl")
	private BoardDao boardDao;

	@Override
	public ListVO getViewList(Map map) throws Exception {
		String pageNo=(String) map.get("pageNo");
		if(pageNo==null||pageNo=="") 
			pageNo="1";
		map.put("pageNo", pageNo);
		List<BoardVO> list=boardDao.getViewList(map);
		
		
		String head=(String)map.get("head");
		int total=boardDao.totalContent(head);
		PagingBean paging=new PagingBean(total,Integer.parseInt(pageNo));
		ListVO lvo=new ListVO(list,paging);
		return lvo;
		
	}

	@Override
	public void addCountView(BoardVO bvo) throws Exception {
		this.boardDao.addCountView(bvo);
		
	}

	@Override
	public BoardVO detailView(BoardVO bvo) throws Exception {
		// TODO Auto-generated method stub
		return this.boardDao.detailView(bvo);
	}

	@Override
	public void deleteBoard(BoardVO bvo) throws Exception {
		// TODO Auto-generated method stub
		this.boardDao.deleteBoard(bvo);
	}

	@Override
	public void updateBoard(BoardVO bvo) throws Exception {


		this.boardDao.updateBoard(bvo);
		
	}

	@Override
	public int write(Map map) throws Exception {
		return this.boardDao.write(map);
		
	}

	@Override
	public void answerWrite(Map map) throws Exception {
		System.out.println("after updateRestep");
		this.boardDao.updateRestep(map);
		System.out.println("before updateRestep");
		this.boardDao.anserWrtite(map);
		
	}

}
